<?php

class Quad_Data_Date extends Quad_Data_Abstract {
	
	public function __construct($date = null) {
		$this->raw = $date;
		$this->date = Quad_Date::create($this->raw);
	}
	
	public static function create($date) {
		return new self($date);
	}
	
	public function __call($m, $a) {
		$m = array($this->date, $m);
		if (is_callable($m)) {
			return call_user_func_array($m, $a);
		}
		throw new Quad_Exception("Unknown function `$m` in class Quad_Data_Date.");
	}
	
	public function __toString() {
		return (string) $this->date;
	}
	
	public function isEmpty() {
		return !$this->isValid();
	}
	
	public function isZero() {
		return preg_match('/^-?0000/', $this->raw);
	}
	
}